{
LANG : PASCAL
PROB : ariprog
}

program ARIPROG;
const
  fi = 'ariprog.in';
  fo = 'ariprog.out';
  maxc = 125000;
  max = 10000;
type
  stt = record
          start, dis : longint;
        end;
var
  free : array[0..maxc] of boolean;
  a : array[1..23000] of longint;
  res : array[1..max] of stt;
  n, m, l, t, s : longint;

procedure inp;
begin
  readln(n);
  readln(m);
end;

procedure init;
var
  i, p, q : longint;
begin
  fillchar(free, sizeof(free), false);
  for p := 0 to m do
    for q := p to m do free[p*p + q*q] := true;
  l := 2*m*m;
  t := 0;
  for i := 0 to l do
    if free[i] then
    begin
      inc(t);
      a[t] := i;
    end;
end;

procedure process;
var
  i, j, k, dis : integer;
  ok : boolean;
begin
  s := 0;
  for i := 1 to t-n+1 do
    for j := i+1 to t do
    begin
      dis := a[j] - a[i];
      if a[i]+dis*(n-1) > l then break;
      ok := true;
      for k := 1 to n-1 do
        if not free[a[i]+k*dis] then
        begin
          ok := false;
          break;
        end;
      if ok then
      begin
        inc(s);
        res[s].start := a[i];
        res[s].dis := dis;
      end;
    end;
end;

procedure swap(i, j : longint);
var
  temp : stt;
begin
  temp := res[i];
  res[i] := res[j];
  res[j] := temp;
end;

function nhohon(x, y : stt) : boolean;
begin
  nhohon := (x.dis < y.dis)
        or ((x.dis = y.dis) and (x.start < y.start));
end;

procedure sort(l, r : longint);
var
  i, j : longint;
  k : stt;
begin
  if l >= r then exit;
  i := l;
  j := r;
  k := res[l+random(r-l+1)];
  repeat
    while nhohon(res[i], k) do inc(i);
    while nhohon(k, res[j]) do dec(j);
    if i <= j then
    begin
      swap(i, j);
      inc(i); dec(j);
    end;
  until i > j;
  sort(i, r);
  sort(l, j);
end;

procedure out;
var
  i, d, c : longint;
begin
  if s = 0 then writeln('NONE')
  else
  begin
    sort(1, s);
    for i := 1 to s do
      with res[i] do writeln(start, ' ', dis);
  end;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  init;
  process;
  out;
  close(output);
  close(input);
end.

12
50

7
76

22
250

5
7


